﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CommonTagTime;
using CommonTagTime.Business;
using CommonTagTime.ModelObject;
using System.IO;
public partial class UserControl_ucRelatedProductItem : System.Web.UI.UserControl
{
    private CommonTagTime.ModelObject.Product product;
    private int categoryID;
    public int CategoryID
    {
        get
        {
            return categoryID;
        }
        set
        {
            categoryID = value;
        }
    }
    public CommonTagTime.ModelObject.Product ProductItem
    {
        get
        {
            return product;
        }
        set
        {
            product = value;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    public string CreateImageTab()
    {
        string imagePage = clsConfigData.DEFAULT_UPLOAD_PRODUCT_THUMBL_NOIMAGE;
        string imageDes = string.Empty;
        //<img src='upload/Product/p1.jpg' class='pImage' alt='' />
        busImageProduct objBus = new busImageProduct();
        ImageProductCollection lstImage = objBus.GetListByProductID(product.ProductID);
        if (lstImage != null && lstImage.Count > 0)
        {
            ImageProduct objImage = lstImage[0];
            if (objImage != null)
            {
                if (File.Exists(this.Page.Server.MapPath(clsConfigData.DEFAULT_UPLOAD_PRODUCT_THUMB_FOLDER + objImage.FileName)))
                    imagePage = clsConfigData.DEFAULT_UPLOAD_PRODUCT_THUMB_FOLDER + objImage.FileName;
                imageDes = objImage.Description;
                if (imageDes == string.Empty)
                    imageDes = product.Name;
            }
        }       
        return "<div style='background-image: url(&quot;" + imagePage + "&quot;);' height='100%' width='100%'>";

    }
    public string GetParamater()
    {
        if (categoryID > 0)
            return "/san-pham/" + clsText.ToSEO(product.Name) + "/" + product.ProductID;
        else
            return "/san-pham/" + clsText.ToSEO(product.Name) + product.ProductID;
    }
}